<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const arr = [10, 20, 30];
        //    1.无起始值
        // const total = arr.reduce(function (prev, current) {
        //     return prev + current;
        // });
        // console.log(total);//60
        // 2.有起始值
        // const total = arr.reduce(function (prev, current) { return prev + current }, 6);
        // console.log(total);//66
        // 3.箭头函数
        const total = arr.reduce((prev, current) => prev + current, 6);
        console.log(total);//66
    </script>
</body>

</html>